<template>
  <Teleport to="body" v-if="dialogVisible">
    <div class="modal-backgrop">
      <div class="modal-box">
        <header>
          <div class="exit">
            <div class="exit-btn" @click="closeModal">
              <img src="@img/login/exit.png" alt="" />
            </div>
          </div>
        </header>
        <main>
          <slot></slot>
        </main>
        <footer>
          <slot name="footer"></slot>
        </footer>
      </div>
    </div>
  </Teleport>
</template>

<script setup lang="ts">
import { ref, markRaw, shallowRef, type Component } from "vue";

const props = defineProps({
  dialogVisible: {
    type: Boolean,
    default: false,
  },
});
const emit = defineEmits(["closeModal", "showLogin"]);
// 关闭弹窗
const closeModal = () => {
  emit("closeModal");
};
</script>

<style lang="scss" scoped>
@import "@assets/css/style.scss";
.modal-backgrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  overflow: hidden;
  z-index: 999;
  .modal-box {
    width: 686px;
    height: 659px;
    background: #ffffff;
    border-radius: 40px;
    position: absolute;
    left: 50%;
    top: 50%;
    // 避免回流 translateZ(0)
    transform: translate(-50%, -50%) translateZ(0);

    @include screen-change(1440px) {
      width: 515px;
      height: 494px;
      border-radius: 30px;
    }
    @include screen-change(1280px) {
      width: 457px;
      height: 439px;
      border-radius: 27px;
    }
    // 关闭按钮
    .exit {
      width: 100%;
      height: 75px;
      display: flex;
      justify-content: flex-end;
      align-items: center;
      @include screen-change(1280px) {
        height: 67px;
      }
      .exit-btn {
        width: 19px;
        height: 19px;
        cursor: pointer;
        margin-right: 32px;
        @include screen-change(1280px) {
          width: 17px;
          height: 17px;
          margin-right: 28px;
        }
        img {
          width: 100%;
          height: 100%;
        }
      }
    }
    .loginOptions {
      margin: 0 45px 23px 45px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 11px;
      background: rgba(250, 240, 240, 0.8);
      @include screen-change(1280px) {
        margin: 0 40px 20px 40px;
        border-radius: 9px;
      }
      div {
        flex: 1;
        height: 52px;
        display: flex;
        align-items: center;
        justify-content: center;

        cursor: pointer;
        transition: background-color 0.3s;
        @include screen-change(1280px) {
          height: 46px;
          border-radius: 9px;
        }
        p {
          font-size: 18px;
          color: #232323;
          @include screen-change(1280px) {
            font-size: 13px;
          }
        }
      }
      .active {
        border-radius: 11px;
        background-color: #c90000;
        @include screen-change(1280px) {
          border-radius: 9px;
        }
        p {
          color: #fff;
        }
      }
    }
  }
}
</style>
